<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>添加</title>
    <#assign base=request.contextPath  />
    <base id="base" href="${base}">
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport"
          content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, adminUser-scalable=0">
    <link rel="stylesheet" href="${base}/static/win10/component/layui/css/layui.css" media="all">

    <script>
        var base = "${base}";
    </script>
    <style>
        .layui-select-title {
            width: 200px;
        }


    </style>
</head>
<body>
<br>
<form class="layui-form " action="">
    <input type="hidden" id="personalId" name="personalId" value="${wechatPersonal.personalId!}">
    <div class="layui-form-item">
        <label class="layui-form-label">姓名</label>
        <div class="layui-input-block">
            <input type="text" id="personalName" name="personalName" value="${wechatPersonal.personalName!}"
                   autocomplete="off" placeholder="请输入名字"
                   class="layui-input">
        </div>
    </div>


    <div class="layui-form-item">
        <label class="layui-form-label">求职状态</label>
        <div class="layui-input-block">
            <@dict_tag type="Job_Searching_Status">
            <#--  name 和lay-filter 为实体类 的属性 -->
                <select id="labelId" name="labelId" lay-filter="labelId">
                <option value=""></option>
                <#if dictList?? && dictList?size gt 0>
                    <#list dictList as dict>
                    <#--判断 回显 -->
                        <#if "${dict.dictK}"== "${wechatPersonal.labelId!}">
                            <option selected value="${dict.dictK}">${dict.dictVal}</option>
                        <#else>
                            <option value="${dict.dictK}">${dict.dictVal}</option>
                        </#if>
                    </#list>

                </#if>
                </select>
            </@dict_tag>

        </div>
    </div>

    <#--<@dict_tag type="Job_Searching_Status" value="求职状态">-->
    <#--${dict.dictVal}-->
    <#--</@dict_tag>-->
    <#--&lt;#&ndash;字典表取List集合 需传入 type类型 &ndash;&gt;-->
    <#--<@dict_tag type="Job_Searching_Status">-->
    <#--<select name="dictType" lay-filter="dictType">-->
    <#--<option value=""></option>-->
    <#--<#if dictList?? && dictList?size gt 0>-->
    <#--<#list dictList as dict>-->
    <#--<option value="${dict.dictK}">${dict.dictVal}</option>-->
    <#--</#list>-->
    <#--</#if>-->
    <#--</select>-->
    <#--</@dict_tag>-->


    <#--<div class="layui-form-item">-->
    <#--<label class="layui-form-label">0男/1女</label>-->
    <#--<div class="layui-input-block">-->
    <#--<input type="text" id="personalGender" name="personalGender" value="${wechatPersonal.personalGender!}"-->
    <#--autocomplete="off" placeholder="请输入0男/1女"-->
    <#--class="layui-input">-->
    <#--</div>-->
    <#--</div>-->


        <div class="layui-form-item">
            <label class="layui-form-label">性别</label>
            <div class="layui-input-block" id="gender">
                <input type="radio" name="sex" value="0" title="男" checked>
                <input type="radio" name="sex" value="1" title="女">
            </div>
        </div>





    <#--<div class="layui-form-item">-->
    <#--<label class="layui-form-label">开始工作时间</label>-->
    <#--<div class="layui-input-block">-->
    <#--<input type="text" id="personalStartTime" name="personalStartTime"-->
    <#--value="${wechatPersonal.personalStartTime!}" autocomplete="off" placeholder="请输入开始工作时间"-->
    <#--class="layui-input">-->
    <#--</div>-->
    <#--</div>-->

    <div class="layui-form-item">
        <label class="layui-form-label">开始工作时间</label>
        <div class="layui-input-block">

            <div class="layui-inline"> <!-- 注意：这一层元素并不是必须的 -->
                <input type="text" value="${wechatPersonal.personalStartTime!}" class="layui-input datatime"
                       id="personalStartTime">
            </div>

        </div>
    </div>


    <#--<div class="layui-form-item">-->
    <#--<label class="layui-form-label">生日</label>-->
    <#--<div class="layui-input-block">-->
    <#--<input type="text" id="personalBirthday" name="personalBirthday" value="${wechatPersonal.personalBirthday!}"-->
    <#--autocomplete="off" placeholder="请输入生日"-->
    <#--class="layui-input">-->
    <#--</div>-->
    <#--</div>-->

    <div class="layui-form-item">
        <label class="layui-form-label">出生日期</label>
        <div class="layui-input-block">
            <div class="layui-inline">
                <input type="text" value="${wechatPersonal.personalBirthday!}" class="layui-input datatime"
                       id="personalBirthday">
            </div>

        </div>
    </div>


    <div class="layui-form-item">
        <label class="layui-form-label">微信号</label>
        <div class="layui-input-block">
            <input type="text" id="personalWecharNumber" name="personalWecharNumber"
                   value="${wechatPersonal.personalWecharNumber!}" autocomplete="off" placeholder="请输入微信号"
                   class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">电话</label>
        <div class="layui-input-block">
            <input type="text" id="personalPhone" name="personalPhone" value="${wechatPersonal.personalPhone!}"
                   autocomplete="off" placeholder="请输入电话"
                   class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">邮箱</label>
        <div class="layui-input-block">
            <input type="text" id="personalEmail" name="personalEmail" value="${wechatPersonal.personalEmail!}"
                   autocomplete="off" placeholder="请输入邮箱"
                   class="layui-input">
        </div>
    </div>
    <#--<div class="layui-form-item">-->
    <#--<label class="layui-form-label">职位名称ID</label>-->
    <#--<div class="layui-input-block">-->
    <#--<input type="text" id="personalPositionId" name="personalPositionId"-->
    <#--value="${wechatPersonal.personalPositionId!}" autocomplete="off" placeholder="请输入职位名称ID"-->
    <#--class="layui-input">-->
    <#--</div>-->
    <#--</div>-->


    <div class="layui-form-item">
        <label class="layui-form-label">职位名称</label>
        <div class="layui-input-block">
            <#--<input type="text" id="paname" name="paname"   autocomplete="off" placeholder="目录名称"-->
            <#--class="layui-input">-->
            <select class="my-sle s_change" style="width: 200px" id="pname" name="pname" lay-filter="aihao" type="button">
                <#--<option value="" >写作</option>-->
                <#--<option value="1">阅读</option>-->
            </select>
        </div>
    </div>


    <#--<div class="layui-form-item">-->
    <#--<label class="layui-form-label">用户头像</label>-->
    <#--<div class="layui-input-block">-->
    <#--<input type="text" id="personalPhoto" name="personalPhoto" value="${wechatPersonal.personalPhoto!}"-->
    <#--autocomplete="off" placeholder="请输入用户头像"-->
    <#--class="layui-input">-->
    <#--</div>-->
    <#--</div>-->


    <div class="layui-form-item">
        <label class="layui-form-label">修改头像</label>
        <div class="layui-input-block">
            <#--//调用头像函数-->
            <div class="layui-upload-drag" id="personalPhoto">
                <i class="layui-icon"></i>
                <p>点击上传，或将文件拖拽到此处</p>

                <#--//调用ID 渲染一张图片  hide 为隐藏-->
                <div class="layui" id="uploadDemoView">
                    <hr>

                    <img src="${wechatPersonal.personalPhoto!}" alt="上传成功后渲染" style="max-width: 196px">
                </div>
            </div>
        </div>
    </div>


    <div align="center">
        <button type="button" class="layui-btn" id="submit">保存</button>
    </div>
</form>

<script src="${base}/static/win10/component/layui/layui.js?t=1"></script>
<script src="${base}/static/win10/js/jquery-1.8.3.min.js?t=1"></script>


<script>


    var personalPositionId =${wechatPersonal.personalPositionId!};

    var urlNew = "${wechatPersonal.personalPhoto!}"
    layui.use(['form', 'layer', 'laydate', 'upload'], function () {


        var form = layui.form
            , layer = layui.layer;
        console.log("personalPositionId:" + personalPositionId)


        $("input[name=sex][value=0]").attr("checked", ${wechatPersonal.personalGender!} == 0 ? true : false
    )
        ;
        $("input[name=sex][value=1]").attr("checked", ${wechatPersonal.personalGender!} == 1 ? true : false
    )
        ;
        form.render();


        var upload = layui.upload;

        //拖拽上传
        upload.render({
            elem: '#personalPhoto'
            , url: '${base}/WeChatUser/setImg' //改成您自己的上传接口
            //res 为对象
            , done: function (res) {
                layer.msg('上传成功');


                console.log(res.data, '====')
                layui.$('#uploadDemoView').removeClass('layui-hide').find('img').attr('src', res.data);
                urlNew = res.data;
                console.log(urlNew)
            }
        });

        $(document).ready(function () {
            $.ajax({
                type: "GET",
                url: base + "/WeChatUser/wechatIndustry/admin/getAllIndustries",
                success: function (data) {
                    console.log(data.data, '----')
                    var str = "";
                    for (var i = 0; i < data.data.length; i++) {
                        // var str = "";
                        if (data.data[i].industryId == personalPositionId) {


                            str = "<option selected value=" + data.data[i].industryId + ">" + data.data[i].industryName + "</option>"
                        } else {
                            str = "<option value=" + data.data[i].industryId + ">" + data.data[i].industryName + "</option>"


                        }
                        $("#pname").append(str)
                    }
                    //给下拉框赋值 重现渲染
                    layui.form.render("select");
                }
            });

        })

        //下拉框多选


        var laydate = layui.laydate;

        //执行一个laydate实例
        laydate.render({
            elem: '#personalStartTime' //指定元素
        });

        laydate.render({
            elem: '#personalBirthday' //指定元素
        });


        $("#submit").on("click", function () {
            if (check() === false) {
                return;
            }

            var gender = $('#gender input[name="sex"]:checked ').val()

            var formDate = {
                personalId: $("#personalId").val(),
                personalName: $("#personalName").val(),
                labelId: $("#labelId").val(),
                personalGender: gender,
                personalStartTime: $("#personalStartTime").val(),
                personalBirthday: $("#personalBirthday").val(),
                personalWecharNumber: $("#personalWecharNumber").val(),
                personalPhone: $("#personalPhone").val(),
                personalEmail: $("#personalEmail").val(),
                personalPositionId: $("#pname").val(),
                // personalUpdateTime: $("#personalUpdateTime").val(),
                // personalCreateTime: $("#personalCreateTime").val(),
                personalPhoto: urlNew
            }
            $.ajax({
                type: "POST",
                url: base + "/WeChatUser/wechatPersonal/admin/editWechatPersonal",
                data: formDate,
                success: function (data) {
                    layer.msg(data.message)
                    if (data.code === 200) {
                        window.location.href = base + "/WeChatUser/wechatPersonal/admin/main.html"
                    } else {

                    }
                }
            });
        })


        function check() {
            if ($("#personalName").val().length < 1) {
                layer.msg("请输入名字");
                return false;
            }
            console.log("labelId:" + $("#labelId").val())
            if ($("#labelId").val().length < 1) {
                layer.msg("请输入求职状态 类型ID");
                return false;
            }
            if ($('#gender input[name="sex"]:checked ').val().length < 1) {
                layer.msg("请输入0男/1女");
                return false;
            }

            console.log("id:" + $("#personalStartTime").val())
            if ($("#personalStartTime").val().length < 1) {
                layer.msg("请输入开始工作时间");
                return false;
            }
            if ($("#personalBirthday").val().length < 1) {
                layer.msg("请输入生日");
                return false;
            }
            if ($("#personalWecharNumber").val().length < 1) {
                layer.msg("请输入微信号");
                return false;
            }
            if ($("#personalPhone").val().length != 11) {

                layer.msg("请输入11位电话号码!当前长度为:" + $("#personalPhone").val().length);
                return false;
            }
            if ($("#personalEmail").val().length < 1) {
                layer.msg("请输入邮箱");
                return false;
            }

            if ($("#pname").val().length < 1) {
                layer.msg("请输入职位名称ID");
                return false;
            }
            // if ($("#personalUpdateTime").val().length < 1) {
            //     layer.msg("请输入修改时间");
            //     return false;
            // }
            // if ($("#personalCreateTime").val().length < 1) {
            //     layer.msg("请输入创建时间");
            //     return false;
            // }
            if (urlNew.length < 1) {
                layer.msg("请输入用户头像");
                return false;
            }
        }
    });

</script>
</body>
</html>